Title: How to Confirm the Email Address on Checkout

Publish Date: Wed, 24 Feb 2021 06:19:02 +0000

Categories: Uncategorized

Content:

How many times did you want to get in touch with your customer after they purchased but their email address was wrong, or they contacted you to change it since they had a typo? I feel this is a common issue with many shop owners. The easy solution is to force customers to confirm the email address on the Checkout page.



Let's see how to do it!









As you probably guessed, this requires a little snippet. Open your functions.php file in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:




https://gist.github.com/SiR-DanieL/87a24568a71ec185916bf2048d9d86a1




The first function adds the field. You can change its label there. You can also change how the field looks like, maybe you want this to show on the same row as the Billing Email field. If you want to do that, I recommend checking this article on the WooCommerce documentation about Customizing checkout fields using actions and filters.



The second function instead confirms if the billing email matches the confirmation billing email. If not, it shows an error on the Checkout page and stops the checkout process. The system will already take care of verifying that the email confirmation field is not empty, so we do not need to verify that ourselves, but we how an error only if the field is not empty. This is because otherwise it would show the matching error even if the Confirm Email Address field is empty, which I did not like.



This is how it looks like on Storefront:







The Confirm Email Address field as shown on the Checkout page with the theme Storefront active.



Did you ever have an issue with wrong billing data on your store? Tell me about it in the comments!
